package Controller;

import Pojo.OrderDetails;
import Service.impl.OrderDetailsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class OrderAndRoomStatusUpdateServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        try {
            String orderIdGet = request.getParameter("orderIdGet");
            String roomNumberGet = request.getParameter("roomNumberGet");//传的是id
            String roomNameGet = request.getParameter("roomNameGet");
            OrderDetailsServiceImpl orderDetailsService=new OrderDetailsServiceImpl();
            OrderDetails orderDetails=new OrderDetails();
            orderDetails.setOrder_id(Integer.parseInt(orderIdGet));
            orderDetails.setRoom_number_id(Integer.parseInt(roomNumberGet));
            orderDetails.setRoom_id(Integer.parseInt(roomNameGet));
            Integer integer=orderDetailsService.OrderAndRoomStatusUpdate(orderDetails);
            response.getWriter().print(integer>0?"success":"fail");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
